<template>
  <div class="content">
    <el-form ref="form" :model="form">
      <div class="search">
        <el-form-item label="姓名" class="label">
          <el-input v-model="form.name" class="input" placeholder="请输入姓名"></el-input>
        </el-form-item>
        <el-form-item label="身份证" class="label">
          <el-input v-model="form.name" placeholder="请输入身份证" class="input"></el-input>
        </el-form-item>
        <el-form-item label="电话" class="label">
          <el-input v-model="form.name" placeholder="请输入电话" class="input"></el-input>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="onSubmit" size="mini">查询</el-button>
        </el-form-item>
        <el-form-item>
          <el-button style="margin:0 30px;" type="primary" @click="onSubmit" size="mini">以图搜人</el-button>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="houseSearh" size="mini">以房搜人</el-button>
        </el-form-item>
        <el-form-item style="width:100%;">
          <div style="float:right;">
            <img src="../../assets/T通用按钮/按钮/导出.png" alt="">
          </div>
        </el-form-item>
      </div>
    </el-form>
    <el-table
      ref="singleTable"
      :data="tableData"
      :header-cell-style="{background: '#EBECF0',height:'44px',color:'#000000'}"
      :cell-style="{background: '#ffffff',height:'44px',color:'#000000'}"
      highlight-current-row
      style="width: 100%"
    >
      <el-table-column label="序号" type="index" :index="indexMethod" width="100"></el-table-column>
      <el-table-column property="name" label="姓名"></el-table-column>
      <el-table-column property="idNum" label="身份证号"></el-table-column>
      <el-table-column property="phone" label="电话"></el-table-column>
      <el-table-column property="sex" label="性别"></el-table-column>
      <el-table-column property="address" label="籍贯"></el-table-column>

      <el-table-column property="address" width="100" label="操作">
        <template slot-scope="scope">
          <el-button type="text" @click="handleClick(scope.row.id)">查看</el-button>
        </template>
      </el-table-column>
    </el-table>
    <div class="pagination">
      <el-pagination
        :current-page.sync="page"
        background
        :page-sizes="[10, 20, 30, 40]"
        :page-size="pageSize"
        layout="total, prev, pager, next, jumper"
        :total="total"
        @current-change="handleCurrentChange"
      />
    </div>
    <!-- 图片放大 -->
    <img-dialog v-if="isShownimg" :img="chooseImg" @closeImg="closeImg"></img-dialog>
    <el-dialog title :visible.sync="dialogFormVisible" width="60%">
      <Dangan></Dangan>
    </el-dialog>
    <el-dialog title="请勾选房屋的单元号" :visible.sync="houseSelectVisible" width="40%">
      <div class="content_scroll house_content">
        <el-tree :data="housedata" show-checkbox node-key="id" :props="defaultProps"></el-tree>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button type="primary" @click="houseSelectVisible = false">选中返回</el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script>
import { mapGetters } from "vuex";
import ImgDialog from "@/components/Imgdialog";
import Dangan from "./dangan";
export default {
  name: "Dashboard",
  data() {
    return {
      form: {},
      tableData: [
        {
          name: "张扬阳",
          sex: "男",
          idNum: "320830199003153421",
          address: "江苏",
          phone: "18712206721"
        }
      ],
      total: 100,
      page: 10,
      pageSize: 10,
      isShownimg: false,
      chooseImg: null,
      dialogFormVisible: false,
      houseSelectVisible: false,
      activeIndex: "1",
      housedata: [
        {
          id: 1,
          label: "新丰苑第一社区",
          children: [
            {
              id: 4,
              label: "新丰苑三期",
              children: [
                {
                  id: 9,
                  label: "1"
                },
                {
                  id: 10,
                  label: "2"
                },
                {
                  id: 19,
                  label: "3"
                },
                {
                  id: 20,
                  label: "4"
                }
              ]
            }
          ]
        },
        {
          id: 2,
          label: "新丰苑第一社区",
          children: [
            {
              id: 5,
              label: "新丰苑三期",
              children: [
                {
                  id: 11,
                  label: "1"
                },
                {
                  id: 12,
                  label: "2"
                }
              ]
            }
          ]
        }
      ],
      defaultProps: {
        children: "children",
        label: "label"
      }
    };
  },
  components: {
    ImgDialog,
    Dangan
  },
  computed: {
    ...mapGetters(["communityId"]),
    indexMethod(index) {
      return (this.page - 1) * 10 + index + 1;
    }
  },
  created() {},
  methods: {
    showImg(img) {
      this.isShownimg = true;
      this.chooseImg = img;
    },
    handleCurrentChange(val) {
      this.page = val;
    },
    closeImg() {
      this.isShownimg = false;
    },
    handleClick(row) {
      // this.detail=JSON.parse(JSON.stringify(row))
      this.dialogFormVisible = true;
    },
    houseSearh() {
      this.houseSelectVisible = true;
    }
  },
  watch: {
    communityId(newVal, oldVal) {
      console.log("changed");
    }
  }
};
</script>
<style lang="scss" scoped>
.content {
  background: #ffffff;
  padding: 25px;
  padding-bottom: 100px;
  min-height: 800px;
  position: relative;
  .search {
    display: flex;
    align-items: flex-end;
    border-bottom: 2px solid #dcdee3;
    margin-bottom: 30px;
    img {
      vertical-align: middle;
    }
  }
  .input {
    width: 246px;
  }
  .label {
    margin-right: 20px;
    color: #666666;
    font-size: 14px;
  }
  .pagination {
    position: absolute;
    right: 0;
    bottom: 0;
    margin: 50px;
  }
  .img {
    width: 50px;
    height: 34px;
  }
}
.title {
  font-size: 20px;
  font-weight: 500;
}
.active {
  color: #0476ff !important;
}
.house_content {
  height: 300px;
  padding-left: 100px;
  overflow-y: scroll;
  overflow-x: hidden;
}
</style>
<style>
.input .el-input__inner {
  height: 28px !important;
}
.el-menu--horizontal > .el-menu-item.is-active {
  border-bottom: 3px solid #0476ff !important;
}
.content_scroll::-webkit-scrollbar {
  width: 10px;
}
.content_scroll::-webkit-scrollbar-thumb {
  border-radius: 10px;
  -webkit-box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.2);
  background: rgba(0, 0, 0, 0.2);
}
.content_scroll::-webkit-scrollbar-track {
  -webkit-box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.2);
  border-radius: 0;
  background: rgba(0, 0, 0, 0.1);
}
</style>
